package com.akxy.pt.tsdb.influxdb.operator;

/**
 * @author Mengfly
 */
public class GroupOperator implements Operator {

    private final String[] columns;

    public GroupOperator(String... columns) {
        this.columns = columns;
    }

    @Override
    public String operatorString() {
        StringBuilder columnsBuilder = new StringBuilder("[");

        for (String column : columns) {
            columnsBuilder.append(String.format("\"%s\"", column)).append(",");
        }
        columnsBuilder.deleteCharAt(columnsBuilder.length() - 1);
        columnsBuilder.append("]");

        return String.format("|> group(columns:%s)", columnsBuilder.toString());
    }
}
